import React from "react";
import '../assets/css/input.css'
function Input(props){
  const {addTodo} = props 
  function Down(e){
  console.log(e)
  if(e.key === "Enter"){
    if(e.target.value === '') return alert('请输入任务')
    addTodo(e.target.value);
    e.target.value = ''
  }
  }

return(
  <>
  <input className="input" placeholder="按下回车键添加任务" onKeyDown={Down} />
  </>
)
}
export default Input;